
package com.eyedog.uilibrary.widgets;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.eyedog.library.utils.DensityUtils;

public class RoundPressedLinearLayout extends LinearLayout {

    public RoundPressedLinearLayout(Context context) {
        this(context,null);
    }

    public RoundPressedLinearLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public RoundPressedLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr,0);
    }

    public RoundPressedLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        setOutlineProvider(new RoundViewOutlineProvider(DensityUtils.dp2px(context, 10)));
        setClipToOutline(true);
    }

    @Override
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        if (isPressed() || isSelected()) {
            setAlpha(0.7f);
        } else {
            setAlpha(1.0f);
        }
    }
}
